/**
 *  <Java Class>
 * This class is the parent to all the others XML Readers like XMLConfigurations.
 * Create the org.xml.sax.XMLReader to read a XML file with SAX.
 * We use SAX because on SimBlock-IDE load we need a quick read about configurations
 * an messages, without maintain all the three of objects in memory
 *
 *   Copyright (C) 2011  Fernando Gil
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   The following additional terms will apply to the software provided with
 *   this file.
 *      1. Preserve the original authors’ names.
 *      2. Documenting all contributions and specify the contributor's name,
 *         the date of the contribution and some email to future contact.
 *
 *   @author  Fernando Gil
 *   @mail    lobho.gil@gmail.com
 *   @company Development Solutions (DS) Software
 *   @date    05-oct-2011 22:49:31
 *   @modify  05-oct-2011 
 *   @by      lobho
 *   @see     License GNU GPL v3  (/lic/GNU_GPLv3_EN)
 *   @see     Additional Terms    Point 7.1 on License (/lic/GNU_GPLv3_EN)
 *   @note   Replicate this header in all classes.
 *
 */

package org.dss.gil.util;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;


public class XMLManager extends DefaultHandler{

    private XMLReader xml_reader;
    private FileReader file_reader;

    public XMLManager() throws SAXException {
        xml_reader = XMLReaderFactory.createXMLReader();
        xml_reader.setContentHandler(this);
        xml_reader.setErrorHandler(this);
    }

    /** Reading XML File. To more datails view the code for every implementation
     * like XMLConfigurations, whe you can find the methods to determine
     * the start and end of elements.
     * @param XMLFile
     * @throws FileNotFoundException
     * @throws IOException
     * @throws SAXException
     */
    public void read(String XMLFile) throws FileNotFoundException, IOException,SAXException {
        file_reader = new FileReader(XMLFile);
        xml_reader.parse(new InputSource(file_reader));
    }

    /*@Override
    public void startDocument() {
        Globals.console("XML Begin");
    }

    @Override
    public void endDocument() {
        Globals.console("XML End");
    }

    public void startElement(String uri, String name,String qName, Attributes atts) {
        Globals.console("Element: " + name);
        for (int i = 0; i < atts.getLength(); i++) {
         Globals.console("Attribute: " + atts.getLocalName(i) + " = "+ atts.getValue(i));
        }
    }
     public void endElement(String uri, String name,String qName) {
        Globals.console("End Element: " + name);
    }
    */


}
